package com.happy.xiao.common.rabbitmq.service;

import com.happy.xiao.common.rabbitmq.bean.MessageReliabilityDelay;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

public interface ICommonMessage {

    /**
     * 普通消息【自动生成信息ID】
     * @param rabbitTemplate
     * @param exchange
     * @param routingKey
     * @param message
     * @return
     * @throws Exception
     */
    boolean sendNormal(RabbitTemplate rabbitTemplate,
                       String exchange,
                       String routingKey,
                       String message) throws Exception;


    /**
     * 普通消息【自动生成信息ID】
     * @param rabbitTemplate
     * @param exchange
     * @param routingKey
     * @param object
     * @param <T>
     * @return
     * @throws Exception
     */
    <T> boolean sendNormal(RabbitTemplate rabbitTemplate,
                           String exchange,
                           String routingKey,
                           T object) throws Exception;


    /**
     * 普通消息
     * @param rabbitTemplate
     * @param exchange
     * @param routingKey
     * @param message
     * @param messageId
     * @return
     * @throws Exception
     */
    boolean sendNormal(RabbitTemplate rabbitTemplate,
                       String exchange,
                       String routingKey,
                       String message,
                       String messageId) throws Exception;


    /**
     * 普通消息
     * @param rabbitTemplate
     * @param exchange
     * @param routingKey
     * @param object
     * @param messageId
     * @param <T>
     * @return
     * @throws Exception
     */
    <T> boolean sendNormal(RabbitTemplate rabbitTemplate,
                           String exchange,
                           String routingKey,
                           T object,
                           String messageId) throws Exception;

    /**
     * 延迟发送消息到队列
     *
     * @param rabbitTemplate
     * @param exchange
     * @param routingKey
     * @param message
     * @param times          延迟时间 单位毫秒
     * @return
     * @throws Exception
     */
    boolean sendDelay(RabbitTemplate rabbitTemplate,
                      String exchange,
                      String routingKey,
                      String message,
                      long times) throws Exception;


    /**
     * 延迟发送消息到队列
     *
     * @param rabbitTemplate
     * @param exchange
     * @param routingKey
     * @param object
     * @param times          单位毫秒
     * @param <T>
     * @return
     * @throws Exception
     */
    <T> boolean sendDelay(RabbitTemplate rabbitTemplate,
                          String exchange,
                          String routingKey,
                          T object,
                          long times) throws Exception;

    /**
     * 延迟发送消息到队列【自动生成信息ID】
     *
     * @param exchange
     * @param routingKey
     * @param message
     * @param times      单位毫秒
     * @return
     * @throws Exception
     */
    boolean sendDelay(RabbitTemplate rabbitTemplate,
                      String exchange,
                      String routingKey,
                      String message,
                      String messageId,
                      long times) throws Exception;


    /**
     * 延迟发送消息到队列【自动生成信息ID】
     *
     * @param exchange
     * @param routingKey
     * @param object
     * @param times      单位毫秒
     * @param <T>
     * @return
     * @throws Exception
     */
    <T> boolean sendDelay(RabbitTemplate rabbitTemplate,
                          String exchange,
                          String routingKey,
                          T object,
                          String messageId,
                          long times) throws Exception;



    // TODO ------------------------------------------------------------------------------------------------------------
    // TODO ----------------------------------------------可靠消息-------------------------------------------------------

//    /**
//     * 发送检查消息【可靠性检查】
//     *
//     * @param object
//     * @return
//     * @throws Exception
//     */
//    boolean sendReliabilityCheckDelayMessage(RabbitTemplate rabbitTemplate, MessageReliabilityDelay object) throws Exception;
//
//    /**
//     * 发送 保证消息可靠性的消息
//     *
//     * @param message 消息内容
//     */
//    boolean sendReliabilityNormalMessage(RabbitTemplate rabbitTemplate,String exchange, String routingKey, String message, String callbackUrl) throws Exception;
//
//    /**
//     * 发送 保证消息可靠性的消息
//     *
//     * @param message 消息内容
//     */
//    boolean sendReliabilityConfirmMessage(RabbitTemplate rabbitTemplate, String message) throws Exception;

    // TODO ------------------------------------------------------------------------------------------------------------

    /**
     * 创建rabbitmq messageID
     * @param key
     * @return
     */
    String createMessageID(String key);

    /**
     * 创建rabbitmq messageID
     * @return
     */
    String createMessageID();
}
